package com.neuedu.service.impl;

import com.neuedu.bean.DeliveryAddress;
import com.neuedu.mapper.DeliveryAddressMapper;
import com.neuedu.service.DeliveryAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeliveryAddressServiceImpl implements DeliveryAddressService {

    @Autowired
    private DeliveryAddressMapper deliveryAddressMapper;


    @Override
    public List<DeliveryAddress> listDeliveryAddressByUserId(String userId) {
        try {
            return deliveryAddressMapper.listDeliveryAddressByUserId(userId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    @Override
    public DeliveryAddress getDeliveryAddressById(Integer daId) {
//        return null;
        try {
            return deliveryAddressMapper.getDeliveryAddressById(daId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    @Override
    public int saveDeliveryAddress(DeliveryAddress deliveryAddress) {
        //        return 0;
        try {
            return deliveryAddressMapper.saveDeliveryAddress(deliveryAddress);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public int removeDeliveryAddress(Integer daId) {
//        return 0;
        try {
            return deliveryAddressMapper.removeDeliveryAddress(daId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public int updateDeliveryAddress(DeliveryAddress deliveryAddress) {
//        return 0;
        try {
            return deliveryAddressMapper.updateDeliveryAddress(deliveryAddress);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
